package adapter;

import android.support.annotation.Nullable;
import android.view.View;
import bean.TestBean;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.dispatchapp.andlei.R;

import java.util.List;

public class OrderDetailAdapter extends BaseQuickAdapter<TestBean, BaseViewHolder> {
    private int i;
    public OrderDetailAdapter(int layoutResId, @Nullable List<TestBean> data,int i) {
        super(layoutResId, data);
        this.i = i;
    }

    @Override
    protected void convert(BaseViewHolder helper, TestBean item) {
        if(helper.getAdapterPosition() == 0){
            helper.getView(R.id.dview_line_left).setVisibility(View.GONE);
        }else {
            helper.getView(R.id.dview_line_left).setVisibility(View.VISIBLE);
        }
        if(helper.getAdapterPosition() == 4){
            helper.getView(R.id.dview_line_right).setVisibility(View.GONE);
        }else {
            helper.getView(R.id.dview_line_right).setVisibility(View.VISIBLE);
        }
        if(item.isSelect){
            helper.getView(R.id.dview_line_left).setBackgroundResource(R.color.green_);
            helper.getView(R.id.dview_line_right).setBackgroundResource(R.color.green_);
            helper.setText(R.id.tv_time,item.time);
            helper.getView(R.id.dview_point).setBackgroundResource(R.drawable.shape_point_green);
        }else {
            if(helper.getAdapterPosition()<=i){
                helper.getView(R.id.dview_line_left).setBackgroundResource(R.color.green_);
            }else {
                helper.getView(R.id.dview_line_left).setBackgroundResource(R.color.gray);
            }
            helper.getView(R.id.dview_line_right).setBackgroundResource(R.color.gray);
            helper.setText(R.id.tv_time,"");
            helper.getView(R.id.dview_point).setBackgroundResource(R.drawable.shape_point_gray);
        }
        helper.setText(R.id.tv_jindu,item.str);
    }
}
